<?php
if( ! defined('BASEPATH')) exit('No direct script access allowed');

class Questions extends CI_Controller
{
	function __construct()
	{
		parent::__construct();
		// check if user logged in
		if(!$this->ion_auth->logged_in()){
			redirect('auth/login');	}
		$this->load->library('form_validation');		
		$this->load->model('client/client_model');
		$this->load->model('client/question_model');
	}

	function my_question()
	{			
		$meta['page_title'] = "My Question";		
		$data['my_questions'] = $this->client_model->client_questions();		
		$this->load->view('common/header', $meta);
		$this->load->view('client/questions',$data);
		$this->load->view('common/footer');
	}
	
	function get_question_by_client_id($id){
		
		//$client_id = isset($id) : $id ? $this->session->userdata('user_id');
		$data['questions'] = $this->client_model->get_question_by_client_id($client_id);
		$meta['page_title'] = "My Question";
			
		$this->load->view('common/header', $meta);
		$this->load->view('user/worksheet',$data);
		$this->load->view('common/footer');
	}
	function answered($ques_id){								
		$this->question_model->answered(($ques_id));		
		redirect('client/questions/my_question');
	}
	
	function answered_ajax(){		
		$this->question_model->answered(($_REQUEST['tId']));	
		
	}
	
	function unanswered($ques_id){	
		$this->question_model->unanswered(($ques_id));
		redirect('client/questions/my_question');
	}
	
	function bulk_actions(){
		$input = $this->input->post();
		echo $qactions = $input['qactions'];		
		$aselected = $input['selected'];					
		 if($qactions == 1){
		 	$this->answered($aselected);			
		 }else{		 	
		 	$this->unanswered($aselected);
		 }
		
		
	}

}

?>